<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>crosspagechannel.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_net_xpc_crosspagechannel.js.html">crosspagechannel.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2007 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Provides the class CrossPageChannel, the main class in
<a name="line17"></a> * goog.net.xpc.
<a name="line18"></a> *
<a name="line19"></a> * @see ../../demos/xpc/index.html
<a name="line20"></a> */
<a name="line21"></a>
<a name="line22"></a>goog.provide(&#39;goog.net.xpc.CrossPageChannel&#39;);
<a name="line23"></a>
<a name="line24"></a>goog.require(&#39;goog.Disposable&#39;);
<a name="line25"></a>goog.require(&#39;goog.Uri&#39;);
<a name="line26"></a>goog.require(&#39;goog.async.Deferred&#39;);
<a name="line27"></a>goog.require(&#39;goog.async.Delay&#39;);
<a name="line28"></a>goog.require(&#39;goog.dom&#39;);
<a name="line29"></a>goog.require(&#39;goog.events&#39;);
<a name="line30"></a>goog.require(&#39;goog.events.EventHandler&#39;);
<a name="line31"></a>goog.require(&#39;goog.json&#39;);
<a name="line32"></a>goog.require(&#39;goog.messaging.AbstractChannel&#39;);
<a name="line33"></a>goog.require(&#39;goog.net.xpc&#39;);
<a name="line34"></a>goog.require(&#39;goog.net.xpc.CrossPageChannelRole&#39;);
<a name="line35"></a>goog.require(&#39;goog.net.xpc.FrameElementMethodTransport&#39;);
<a name="line36"></a>goog.require(&#39;goog.net.xpc.IframePollingTransport&#39;);
<a name="line37"></a>goog.require(&#39;goog.net.xpc.IframeRelayTransport&#39;);
<a name="line38"></a>goog.require(&#39;goog.net.xpc.NativeMessagingTransport&#39;);
<a name="line39"></a>goog.require(&#39;goog.net.xpc.NixTransport&#39;);
<a name="line40"></a>goog.require(&#39;goog.net.xpc.Transport&#39;);
<a name="line41"></a>goog.require(&#39;goog.userAgent&#39;);
<a name="line42"></a>
<a name="line43"></a>
<a name="line44"></a>
<a name="line45"></a>/**
<a name="line46"></a> * A communication channel between two documents from different domains.
<a name="line47"></a> * Provides asynchronous messaging.
<a name="line48"></a> *
<a name="line49"></a> * @param {Object} cfg Channel configuration object.
<a name="line50"></a> * @param {goog.dom.DomHelper=} opt_domHelper The optional dom helper to
<a name="line51"></a> *     use for looking up elements in the dom.
<a name="line52"></a> * @constructor
<a name="line53"></a> * @extends {goog.messaging.AbstractChannel}
<a name="line54"></a> */
<a name="line55"></a>goog.net.xpc.CrossPageChannel = function(cfg, opt_domHelper) {
<a name="line56"></a>  goog.base(this);
<a name="line57"></a>
<a name="line58"></a>  for (var i = 0, uriField; uriField = goog.net.xpc.UriCfgFields[i]; i++) {
<a name="line59"></a>    if (uriField in cfg &amp;&amp; !/^https?:\/\//.test(cfg[uriField])) {
<a name="line60"></a>      throw Error(&#39;URI &#39; + cfg[uriField] + &#39; is invalid for field &#39; + uriField);
<a name="line61"></a>    }
<a name="line62"></a>  }
<a name="line63"></a>
<a name="line64"></a>  /**
<a name="line65"></a>   * The configuration for this channel.
<a name="line66"></a>   * @type {Object}
<a name="line67"></a>   * @private
<a name="line68"></a>   */
<a name="line69"></a>  this.cfg_ = cfg;
<a name="line70"></a>
<a name="line71"></a>  /**
<a name="line72"></a>   * The name of the channel.
<a name="line73"></a>   * @type {string}
<a name="line74"></a>   */
<a name="line75"></a>  this.name = this.cfg_[goog.net.xpc.CfgFields.CHANNEL_NAME] ||
<a name="line76"></a>      goog.net.xpc.getRandomString(10);
<a name="line77"></a>
<a name="line78"></a>  /**
<a name="line79"></a>   * The dom helper to use for accessing the dom.
<a name="line80"></a>   * @type {goog.dom.DomHelper}
<a name="line81"></a>   * @private
<a name="line82"></a>   */
<a name="line83"></a>  this.domHelper_ = opt_domHelper || goog.dom.getDomHelper();
<a name="line84"></a>
<a name="line85"></a>  /**
<a name="line86"></a>   * Collects deferred function calls which will be made once the connection
<a name="line87"></a>   * has been fully set up.
<a name="line88"></a>   * @type {!Array.&lt;function()&gt;}
<a name="line89"></a>   * @private
<a name="line90"></a>   */
<a name="line91"></a>  this.deferredDeliveries_ = [];
<a name="line92"></a>
<a name="line93"></a>  /**
<a name="line94"></a>   * An event handler used to listen for load events on peer iframes.
<a name="line95"></a>   * @type {!goog.events.EventHandler}
<a name="line96"></a>   * @private
<a name="line97"></a>   */
<a name="line98"></a>  this.peerLoadHandler_ = new goog.events.EventHandler(this);
<a name="line99"></a>
<a name="line100"></a>  // If LOCAL_POLL_URI or PEER_POLL_URI is not available, try using
<a name="line101"></a>  // robots.txt from that host.
<a name="line102"></a>  cfg[goog.net.xpc.CfgFields.LOCAL_POLL_URI] =
<a name="line103"></a>      cfg[goog.net.xpc.CfgFields.LOCAL_POLL_URI] ||
<a name="line104"></a>      goog.uri.utils.getHost(this.domHelper_.getWindow().location.href) +
<a name="line105"></a>          &#39;/robots.txt&#39;;
<a name="line106"></a>  // PEER_URI is sometimes undefined in tests.
<a name="line107"></a>  cfg[goog.net.xpc.CfgFields.PEER_POLL_URI] =
<a name="line108"></a>      cfg[goog.net.xpc.CfgFields.PEER_POLL_URI] ||
<a name="line109"></a>      goog.uri.utils.getHost(cfg[goog.net.xpc.CfgFields.PEER_URI] || &#39;&#39;) +
<a name="line110"></a>          &#39;/robots.txt&#39;;
<a name="line111"></a>
<a name="line112"></a>  goog.net.xpc.channels[this.name] = this;
<a name="line113"></a>
<a name="line114"></a>  goog.events.listen(window, &#39;unload&#39;,
<a name="line115"></a>      goog.net.xpc.CrossPageChannel.disposeAll_);
<a name="line116"></a>
<a name="line117"></a>  goog.net.xpc.logger.info(&#39;CrossPageChannel created: &#39; + this.name);
<a name="line118"></a>};
<a name="line119"></a>goog.inherits(goog.net.xpc.CrossPageChannel, goog.messaging.AbstractChannel);
<a name="line120"></a>
<a name="line121"></a>
<a name="line122"></a>/**
<a name="line123"></a> * Regexp for escaping service names.
<a name="line124"></a> * @type {RegExp}
<a name="line125"></a> * @private
<a name="line126"></a> */
<a name="line127"></a>goog.net.xpc.CrossPageChannel.TRANSPORT_SERVICE_ESCAPE_RE_ =
<a name="line128"></a>    new RegExp(&#39;^%*&#39; + goog.net.xpc.TRANSPORT_SERVICE_ + &#39;$&#39;);
<a name="line129"></a>
<a name="line130"></a>
<a name="line131"></a>/**
<a name="line132"></a> * Regexp for unescaping service names.
<a name="line133"></a> * @type {RegExp}
<a name="line134"></a> * @private
<a name="line135"></a> */
<a name="line136"></a>goog.net.xpc.CrossPageChannel.TRANSPORT_SERVICE_UNESCAPE_RE_ =
<a name="line137"></a>    new RegExp(&#39;^%+&#39; + goog.net.xpc.TRANSPORT_SERVICE_ + &#39;$&#39;);
<a name="line138"></a>
<a name="line139"></a>
<a name="line140"></a>/**
<a name="line141"></a> * A delay between the transport reporting as connected and the calling of the
<a name="line142"></a> * connection callback.  Sometimes used to paper over timing vulnerabilities.
<a name="line143"></a> * @type {goog.async.Delay}
<a name="line144"></a> * @private
<a name="line145"></a> */
<a name="line146"></a>goog.net.xpc.CrossPageChannel.prototype.connectionDelay_ = null;
<a name="line147"></a>
<a name="line148"></a>
<a name="line149"></a>/**
<a name="line150"></a> * A deferred which is set to non-null while a peer iframe is being created
<a name="line151"></a> * but has not yet thrown its load event, and which fires when that load event
<a name="line152"></a> * arrives.
<a name="line153"></a> * @type {goog.async.Deferred}
<a name="line154"></a> * @private
<a name="line155"></a> */
<a name="line156"></a>goog.net.xpc.CrossPageChannel.prototype.peerWindowDeferred_ = null;
<a name="line157"></a>
<a name="line158"></a>
<a name="line159"></a>/**
<a name="line160"></a> * The transport.
<a name="line161"></a> * @type {goog.net.xpc.Transport?}
<a name="line162"></a> * @private
<a name="line163"></a> */
<a name="line164"></a>goog.net.xpc.CrossPageChannel.prototype.transport_ = null;
<a name="line165"></a>
<a name="line166"></a>
<a name="line167"></a>/**
<a name="line168"></a> * The channel state.
<a name="line169"></a> * @type {number}
<a name="line170"></a> * @private
<a name="line171"></a> */
<a name="line172"></a>goog.net.xpc.CrossPageChannel.prototype.state_ =
<a name="line173"></a>    goog.net.xpc.ChannelStates.NOT_CONNECTED;
<a name="line174"></a>
<a name="line175"></a>
<a name="line176"></a>/**
<a name="line177"></a> * @override
<a name="line178"></a> * @return {boolean} Whether the channel is connected.
<a name="line179"></a> */
<a name="line180"></a>goog.net.xpc.CrossPageChannel.prototype.isConnected = function() {
<a name="line181"></a>  return this.state_ == goog.net.xpc.ChannelStates.CONNECTED;
<a name="line182"></a>};
<a name="line183"></a>
<a name="line184"></a>
<a name="line185"></a>/**
<a name="line186"></a> * Reference to the window-object of the peer page.
<a name="line187"></a> * @type {Object}
<a name="line188"></a> * @private
<a name="line189"></a> */
<a name="line190"></a>goog.net.xpc.CrossPageChannel.prototype.peerWindowObject_ = null;
<a name="line191"></a>
<a name="line192"></a>
<a name="line193"></a>/**
<a name="line194"></a> * Reference to the iframe-element.
<a name="line195"></a> * @type {Object}
<a name="line196"></a> * @private
<a name="line197"></a> */
<a name="line198"></a>goog.net.xpc.CrossPageChannel.prototype.iframeElement_ = null;
<a name="line199"></a>
<a name="line200"></a>
<a name="line201"></a>/**
<a name="line202"></a> * Returns the configuration object for this channel.
<a name="line203"></a> * Package private. Do not call from outside goog.net.xpc.
<a name="line204"></a> *
<a name="line205"></a> * @return {Object} The configuration object for this channel.
<a name="line206"></a> */
<a name="line207"></a>goog.net.xpc.CrossPageChannel.prototype.getConfig = function() {
<a name="line208"></a>  return this.cfg_;
<a name="line209"></a>};
<a name="line210"></a>
<a name="line211"></a>
<a name="line212"></a>/**
<a name="line213"></a> * Returns a reference to the iframe-element.
<a name="line214"></a> * Package private. Do not call from outside goog.net.xpc.
<a name="line215"></a> *
<a name="line216"></a> * @return {Object} A reference to the iframe-element.
<a name="line217"></a> */
<a name="line218"></a>goog.net.xpc.CrossPageChannel.prototype.getIframeElement = function() {
<a name="line219"></a>  return this.iframeElement_;
<a name="line220"></a>};
<a name="line221"></a>
<a name="line222"></a>
<a name="line223"></a>/**
<a name="line224"></a> * Sets the window object the foreign document resides in.
<a name="line225"></a> *
<a name="line226"></a> * @param {Object} peerWindowObject The window object of the peer.
<a name="line227"></a> */
<a name="line228"></a>goog.net.xpc.CrossPageChannel.prototype.setPeerWindowObject =
<a name="line229"></a>    function(peerWindowObject) {
<a name="line230"></a>  this.peerWindowObject_ = peerWindowObject;
<a name="line231"></a>};
<a name="line232"></a>
<a name="line233"></a>
<a name="line234"></a>/**
<a name="line235"></a> * Returns the window object the foreign document resides in.
<a name="line236"></a> * Package private. Do not call from outside goog.net.xpc.
<a name="line237"></a> *
<a name="line238"></a> * @return {Object} The window object of the peer.
<a name="line239"></a> */
<a name="line240"></a>goog.net.xpc.CrossPageChannel.prototype.getPeerWindowObject = function() {
<a name="line241"></a>  return this.peerWindowObject_;
<a name="line242"></a>};
<a name="line243"></a>
<a name="line244"></a>
<a name="line245"></a>/**
<a name="line246"></a> * Determines whether the peer window is available (e.g. not closed).
<a name="line247"></a> * Package private. Do not call from outside goog.net.xpc.
<a name="line248"></a> *
<a name="line249"></a> * @return {boolean} Whether the peer window is available.
<a name="line250"></a> */
<a name="line251"></a>goog.net.xpc.CrossPageChannel.prototype.isPeerAvailable = function() {
<a name="line252"></a>  // NOTE(user): This check is not reliable in IE, where a document in an
<a name="line253"></a>  // iframe does not get unloaded when removing the iframe element from the DOM.
<a name="line254"></a>  // TODO(user): Find something that works in IE as well.
<a name="line255"></a>  // NOTE(user): &quot;!this.peerWindowObject_.closed&quot; evaluates to &#39;false&#39; in IE9
<a name="line256"></a>  // sometimes even though typeof(this.peerWindowObject_.closed) is boolean and
<a name="line257"></a>  // this.peerWindowObject_.closed evaluates to &#39;false&#39;. Casting it to a Boolean
<a name="line258"></a>  // results in sane evaluation. When this happens, it&#39;s in the inner iframe
<a name="line259"></a>  // when querying its parent&#39;s &#39;closed&#39; status. Note that this is a different
<a name="line260"></a>  // case than mibuerge@&#39;s note above.
<a name="line261"></a>  try {
<a name="line262"></a>    return !!this.peerWindowObject_ &amp;&amp; !Boolean(this.peerWindowObject_.closed);
<a name="line263"></a>  } catch (e) {
<a name="line264"></a>    // If the window is closing, an error may be thrown.
<a name="line265"></a>    return false;
<a name="line266"></a>  }
<a name="line267"></a>};
<a name="line268"></a>
<a name="line269"></a>
<a name="line270"></a>/**
<a name="line271"></a> * Determine which transport type to use for this channel / useragent.
<a name="line272"></a> * @return {goog.net.xpc.TransportTypes|undefined} The best transport type.
<a name="line273"></a> * @private
<a name="line274"></a> */
<a name="line275"></a>goog.net.xpc.CrossPageChannel.prototype.determineTransportType_ = function() {
<a name="line276"></a>  var transportType;
<a name="line277"></a>  if (goog.isFunction(document.postMessage) ||
<a name="line278"></a>      goog.isFunction(window.postMessage) ||
<a name="line279"></a>      // IE8 supports window.postMessage, but
<a name="line280"></a>      // typeof window.postMessage returns &quot;object&quot;
<a name="line281"></a>      (goog.userAgent.IE &amp;&amp; window.postMessage)) {
<a name="line282"></a>    transportType = goog.net.xpc.TransportTypes.NATIVE_MESSAGING;
<a name="line283"></a>  } else if (goog.userAgent.GECKO) {
<a name="line284"></a>    transportType = goog.net.xpc.TransportTypes.FRAME_ELEMENT_METHOD;
<a name="line285"></a>  } else if (goog.userAgent.IE &amp;&amp;
<a name="line286"></a>             this.cfg_[goog.net.xpc.CfgFields.PEER_RELAY_URI]) {
<a name="line287"></a>    transportType = goog.net.xpc.TransportTypes.IFRAME_RELAY;
<a name="line288"></a>  } else if (goog.userAgent.IE &amp;&amp; goog.net.xpc.NixTransport.isNixSupported()) {
<a name="line289"></a>    transportType = goog.net.xpc.TransportTypes.NIX;
<a name="line290"></a>  } else {
<a name="line291"></a>    transportType = goog.net.xpc.TransportTypes.IFRAME_POLLING;
<a name="line292"></a>  }
<a name="line293"></a>  return transportType;
<a name="line294"></a>};
<a name="line295"></a>
<a name="line296"></a>
<a name="line297"></a>/**
<a name="line298"></a> * Creates the transport for this channel. Chooses from the available
<a name="line299"></a> * transport based on the user agent and the configuration.
<a name="line300"></a> * @private
<a name="line301"></a> */
<a name="line302"></a>goog.net.xpc.CrossPageChannel.prototype.createTransport_ = function() {
<a name="line303"></a>  // return, if the transport has already been created
<a name="line304"></a>  if (this.transport_) {
<a name="line305"></a>    return;
<a name="line306"></a>  }
<a name="line307"></a>
<a name="line308"></a>  if (!this.cfg_[goog.net.xpc.CfgFields.TRANSPORT]) {
<a name="line309"></a>    this.cfg_[goog.net.xpc.CfgFields.TRANSPORT] =
<a name="line310"></a>        this.determineTransportType_();
<a name="line311"></a>  }
<a name="line312"></a>
<a name="line313"></a>  switch (this.cfg_[goog.net.xpc.CfgFields.TRANSPORT]) {
<a name="line314"></a>    case goog.net.xpc.TransportTypes.NATIVE_MESSAGING:
<a name="line315"></a>      var protocolVersion = this.cfg_[
<a name="line316"></a>          goog.net.xpc.CfgFields.NATIVE_TRANSPORT_PROTOCOL_VERSION] || 2;
<a name="line317"></a>      this.transport_ = new goog.net.xpc.NativeMessagingTransport(
<a name="line318"></a>          this,
<a name="line319"></a>          this.cfg_[goog.net.xpc.CfgFields.PEER_HOSTNAME],
<a name="line320"></a>          this.domHelper_,
<a name="line321"></a>          !!this.cfg_[goog.net.xpc.CfgFields.ONE_SIDED_HANDSHAKE],
<a name="line322"></a>          protocolVersion);
<a name="line323"></a>      break;
<a name="line324"></a>    case goog.net.xpc.TransportTypes.NIX:
<a name="line325"></a>      this.transport_ = new goog.net.xpc.NixTransport(this, this.domHelper_);
<a name="line326"></a>      break;
<a name="line327"></a>    case goog.net.xpc.TransportTypes.FRAME_ELEMENT_METHOD:
<a name="line328"></a>      this.transport_ =
<a name="line329"></a>          new goog.net.xpc.FrameElementMethodTransport(this, this.domHelper_);
<a name="line330"></a>      break;
<a name="line331"></a>    case goog.net.xpc.TransportTypes.IFRAME_RELAY:
<a name="line332"></a>      this.transport_ =
<a name="line333"></a>          new goog.net.xpc.IframeRelayTransport(this, this.domHelper_);
<a name="line334"></a>      break;
<a name="line335"></a>    case goog.net.xpc.TransportTypes.IFRAME_POLLING:
<a name="line336"></a>      this.transport_ =
<a name="line337"></a>          new goog.net.xpc.IframePollingTransport(this, this.domHelper_);
<a name="line338"></a>      break;
<a name="line339"></a>  }
<a name="line340"></a>
<a name="line341"></a>  if (this.transport_) {
<a name="line342"></a>    goog.net.xpc.logger.info(&#39;Transport created: &#39; + this.transport_.getName());
<a name="line343"></a>  } else {
<a name="line344"></a>    throw Error(&#39;CrossPageChannel: No suitable transport found!&#39;);
<a name="line345"></a>  }
<a name="line346"></a>};
<a name="line347"></a>
<a name="line348"></a>
<a name="line349"></a>/**
<a name="line350"></a> * Returns the transport type in use for this channel.
<a name="line351"></a> * @return {number} Transport-type identifier.
<a name="line352"></a> */
<a name="line353"></a>goog.net.xpc.CrossPageChannel.prototype.getTransportType = function() {
<a name="line354"></a>  return this.transport_.getType();
<a name="line355"></a>};
<a name="line356"></a>
<a name="line357"></a>
<a name="line358"></a>/**
<a name="line359"></a> * Returns the tranport name in use for this channel.
<a name="line360"></a> * @return {string} The transport name.
<a name="line361"></a> */
<a name="line362"></a>goog.net.xpc.CrossPageChannel.prototype.getTransportName = function() {
<a name="line363"></a>  return this.transport_.getName();
<a name="line364"></a>};
<a name="line365"></a>
<a name="line366"></a>
<a name="line367"></a>/**
<a name="line368"></a> * @return {Object} Configuration-object to be used by the peer to
<a name="line369"></a> *     initialize the channel.
<a name="line370"></a> */
<a name="line371"></a>goog.net.xpc.CrossPageChannel.prototype.getPeerConfiguration = function() {
<a name="line372"></a>  var peerCfg = {};
<a name="line373"></a>  peerCfg[goog.net.xpc.CfgFields.CHANNEL_NAME] = this.name;
<a name="line374"></a>  peerCfg[goog.net.xpc.CfgFields.TRANSPORT] =
<a name="line375"></a>      this.cfg_[goog.net.xpc.CfgFields.TRANSPORT];
<a name="line376"></a>  peerCfg[goog.net.xpc.CfgFields.ONE_SIDED_HANDSHAKE] =
<a name="line377"></a>      this.cfg_[goog.net.xpc.CfgFields.ONE_SIDED_HANDSHAKE];
<a name="line378"></a>
<a name="line379"></a>  if (this.cfg_[goog.net.xpc.CfgFields.LOCAL_RELAY_URI]) {
<a name="line380"></a>    peerCfg[goog.net.xpc.CfgFields.PEER_RELAY_URI] =
<a name="line381"></a>        this.cfg_[goog.net.xpc.CfgFields.LOCAL_RELAY_URI];
<a name="line382"></a>  }
<a name="line383"></a>  if (this.cfg_[goog.net.xpc.CfgFields.LOCAL_POLL_URI]) {
<a name="line384"></a>    peerCfg[goog.net.xpc.CfgFields.PEER_POLL_URI] =
<a name="line385"></a>        this.cfg_[goog.net.xpc.CfgFields.LOCAL_POLL_URI];
<a name="line386"></a>  }
<a name="line387"></a>  if (this.cfg_[goog.net.xpc.CfgFields.PEER_POLL_URI]) {
<a name="line388"></a>    peerCfg[goog.net.xpc.CfgFields.LOCAL_POLL_URI] =
<a name="line389"></a>        this.cfg_[goog.net.xpc.CfgFields.PEER_POLL_URI];
<a name="line390"></a>  }
<a name="line391"></a>  var role = this.cfg_[goog.net.xpc.CfgFields.ROLE];
<a name="line392"></a>  if (role) {
<a name="line393"></a>    peerCfg[goog.net.xpc.CfgFields.ROLE] =
<a name="line394"></a>        role == goog.net.xpc.CrossPageChannelRole.INNER ?
<a name="line395"></a>            goog.net.xpc.CrossPageChannelRole.OUTER :
<a name="line396"></a>            goog.net.xpc.CrossPageChannelRole.INNER;
<a name="line397"></a>  }
<a name="line398"></a>
<a name="line399"></a>  return peerCfg;
<a name="line400"></a>};
<a name="line401"></a>
<a name="line402"></a>
<a name="line403"></a>/**
<a name="line404"></a> * Creates the iframe containing the peer page in a specified parent element.
<a name="line405"></a> * This method does not connect the channel, connect() still has to be called
<a name="line406"></a> * separately.
<a name="line407"></a> *
<a name="line408"></a> * @param {!Element} parentElm The container element the iframe is appended to.
<a name="line409"></a> * @param {Function=} opt_configureIframeCb If present, this function gets
<a name="line410"></a> *     called with the iframe element as parameter to allow setting properties
<a name="line411"></a> *     on it before it gets added to the DOM. If absent, the iframe&#39;s width and
<a name="line412"></a> *     height are set to &#39;100%&#39;.
<a name="line413"></a> * @param {boolean=} opt_addCfgParam Whether to add the peer configuration as
<a name="line414"></a> *     URL parameter (default: true).
<a name="line415"></a> * @return {!HTMLIFrameElement} The iframe element.
<a name="line416"></a> */
<a name="line417"></a>goog.net.xpc.CrossPageChannel.prototype.createPeerIframe = function(
<a name="line418"></a>    parentElm, opt_configureIframeCb, opt_addCfgParam) {
<a name="line419"></a>  goog.net.xpc.logger.info(&#39;createPeerIframe()&#39;);
<a name="line420"></a>
<a name="line421"></a>  var iframeId = this.cfg_[goog.net.xpc.CfgFields.IFRAME_ID];
<a name="line422"></a>  if (!iframeId) {
<a name="line423"></a>    // Create a randomized ID for the iframe element to avoid
<a name="line424"></a>    // bfcache-related issues.
<a name="line425"></a>    iframeId = this.cfg_[goog.net.xpc.CfgFields.IFRAME_ID] =
<a name="line426"></a>        &#39;xpcpeer&#39; + goog.net.xpc.getRandomString(4);
<a name="line427"></a>  }
<a name="line428"></a>
<a name="line429"></a>  // TODO(user) Opera creates a history-entry when creating an iframe
<a name="line430"></a>  // programmatically as follows. Find a way which avoids this.
<a name="line431"></a>
<a name="line432"></a>  var iframeElm = goog.dom.getDomHelper(parentElm).createElement(&#39;IFRAME&#39;);
<a name="line433"></a>  iframeElm.id = iframeElm.name = iframeId;
<a name="line434"></a>  if (opt_configureIframeCb) {
<a name="line435"></a>    opt_configureIframeCb(iframeElm);
<a name="line436"></a>  } else {
<a name="line437"></a>    iframeElm.style.width = iframeElm.style.height = &#39;100%&#39;;
<a name="line438"></a>  }
<a name="line439"></a>
<a name="line440"></a>  this.cleanUpIncompleteConnection_();
<a name="line441"></a>  this.peerWindowDeferred_ =
<a name="line442"></a>      new goog.async.Deferred(undefined, this);
<a name="line443"></a>  var peerUri = this.getPeerUri(opt_addCfgParam);
<a name="line444"></a>  this.peerLoadHandler_.listenOnce(iframeElm, &#39;load&#39;,
<a name="line445"></a>      this.peerWindowDeferred_.callback, false, this.peerWindowDeferred_);
<a name="line446"></a>
<a name="line447"></a>  if (goog.userAgent.GECKO || goog.userAgent.WEBKIT) {
<a name="line448"></a>    // Appending the iframe in a timeout to avoid a weird fastback issue, which
<a name="line449"></a>    // is present in Safari and Gecko.
<a name="line450"></a>    window.setTimeout(
<a name="line451"></a>        goog.bind(function() {
<a name="line452"></a>          parentElm.appendChild(iframeElm);
<a name="line453"></a>          iframeElm.src = peerUri.toString();
<a name="line454"></a>          goog.net.xpc.logger.info(&#39;peer iframe created (&#39; + iframeId + &#39;)&#39;);
<a name="line455"></a>        }, this), 1);
<a name="line456"></a>  } else {
<a name="line457"></a>    iframeElm.src = peerUri.toString();
<a name="line458"></a>    parentElm.appendChild(iframeElm);
<a name="line459"></a>    goog.net.xpc.logger.info(&#39;peer iframe created (&#39; + iframeId + &#39;)&#39;);
<a name="line460"></a>  }
<a name="line461"></a>
<a name="line462"></a>  return /** @type {!HTMLIFrameElement} */ (iframeElm);
<a name="line463"></a>};
<a name="line464"></a>
<a name="line465"></a>
<a name="line466"></a>/**
<a name="line467"></a> * Clean up after any incomplete attempt to establish and connect to a peer
<a name="line468"></a> * iframe.
<a name="line469"></a> * @private
<a name="line470"></a> */
<a name="line471"></a>goog.net.xpc.CrossPageChannel.prototype.cleanUpIncompleteConnection_ =
<a name="line472"></a>    function() {
<a name="line473"></a>  if (this.peerWindowDeferred_) {
<a name="line474"></a>    this.peerWindowDeferred_.cancel();
<a name="line475"></a>    this.peerWindowDeferred_ = null;
<a name="line476"></a>  }
<a name="line477"></a>  this.deferredDeliveries_.length = 0;
<a name="line478"></a>  this.peerLoadHandler_.removeAll();
<a name="line479"></a>};
<a name="line480"></a>
<a name="line481"></a>
<a name="line482"></a>/**
<a name="line483"></a> * Returns the peer URI, with an optional URL parameter for configuring the peer
<a name="line484"></a> * window.
<a name="line485"></a> *
<a name="line486"></a> * @param {boolean=} opt_addCfgParam Whether to add the peer configuration as
<a name="line487"></a> *     URL parameter (default: true).
<a name="line488"></a> * @return {!goog.Uri} The peer URI.
<a name="line489"></a> */
<a name="line490"></a>goog.net.xpc.CrossPageChannel.prototype.getPeerUri = function(opt_addCfgParam) {
<a name="line491"></a>  var peerUri = this.cfg_[goog.net.xpc.CfgFields.PEER_URI];
<a name="line492"></a>  if (goog.isString(peerUri)) {
<a name="line493"></a>    peerUri = this.cfg_[goog.net.xpc.CfgFields.PEER_URI] =
<a name="line494"></a>        new goog.Uri(peerUri);
<a name="line495"></a>  }
<a name="line496"></a>
<a name="line497"></a>  // Add the channel configuration used by the peer as URL parameter.
<a name="line498"></a>  if (opt_addCfgParam !== false) {
<a name="line499"></a>    peerUri.setParameterValue(&#39;xpc&#39;,
<a name="line500"></a>                              goog.json.serialize(
<a name="line501"></a>                                  this.getPeerConfiguration()));
<a name="line502"></a>  }
<a name="line503"></a>
<a name="line504"></a>  return peerUri;
<a name="line505"></a>};
<a name="line506"></a>
<a name="line507"></a>
<a name="line508"></a>/**
<a name="line509"></a> * Initiates connecting the channel. When this method is called, all the
<a name="line510"></a> * information needed to connect the channel has to be available.
<a name="line511"></a> *
<a name="line512"></a> * @override
<a name="line513"></a> * @param {Function=} opt_connectCb The function to be called when the
<a name="line514"></a> * channel has been connected and is ready to be used.
<a name="line515"></a> */
<a name="line516"></a>goog.net.xpc.CrossPageChannel.prototype.connect = function(opt_connectCb) {
<a name="line517"></a>  this.connectCb_ = opt_connectCb || goog.nullFunction;
<a name="line518"></a>
<a name="line519"></a>  // If we know of a peer window whose creation has been requested but is not
<a name="line520"></a>  // complete, peerWindowDeferred_ will be non-null, and we should block on it.
<a name="line521"></a>  if (this.peerWindowDeferred_) {
<a name="line522"></a>    this.peerWindowDeferred_.addCallback(this.continueConnection_);
<a name="line523"></a>  } else {
<a name="line524"></a>    this.continueConnection_();
<a name="line525"></a>  }
<a name="line526"></a>};
<a name="line527"></a>
<a name="line528"></a>
<a name="line529"></a>/**
<a name="line530"></a> * Continues the connection process once we&#39;re as sure as we can be that the
<a name="line531"></a> * peer iframe has been created.
<a name="line532"></a> * @private
<a name="line533"></a> */
<a name="line534"></a>goog.net.xpc.CrossPageChannel.prototype.continueConnection_ = function() {
<a name="line535"></a>  goog.net.xpc.logger.info(&#39;continueConnection_()&#39;);
<a name="line536"></a>  this.peerWindowDeferred_ = null;
<a name="line537"></a>  if (this.cfg_[goog.net.xpc.CfgFields.IFRAME_ID]) {
<a name="line538"></a>    this.iframeElement_ = this.domHelper_.getElement(
<a name="line539"></a>        this.cfg_[goog.net.xpc.CfgFields.IFRAME_ID]);
<a name="line540"></a>  }
<a name="line541"></a>  if (this.iframeElement_) {
<a name="line542"></a>    var winObj = this.iframeElement_.contentWindow;
<a name="line543"></a>    // accessing the window using contentWindow doesn&#39;t work in safari
<a name="line544"></a>    if (!winObj) {
<a name="line545"></a>      winObj = window.frames[this.cfg_[goog.net.xpc.CfgFields.IFRAME_ID]];
<a name="line546"></a>    }
<a name="line547"></a>    this.setPeerWindowObject(winObj);
<a name="line548"></a>  }
<a name="line549"></a>
<a name="line550"></a>  // if the peer window object has not been set at this point, we assume
<a name="line551"></a>  // being in an iframe and the channel is meant to be to the containing page
<a name="line552"></a>  if (!this.peerWindowObject_) {
<a name="line553"></a>    // throw an error if we are in the top window (== not in an iframe)
<a name="line554"></a>    if (window == window.top) {
<a name="line555"></a>      throw Error(
<a name="line556"></a>          &quot;CrossPageChannel: Can&#39;t connect, peer window-object not set.&quot;);
<a name="line557"></a>    } else {
<a name="line558"></a>      this.setPeerWindowObject(window.parent);
<a name="line559"></a>    }
<a name="line560"></a>  }
<a name="line561"></a>
<a name="line562"></a>  this.createTransport_();
<a name="line563"></a>
<a name="line564"></a>  this.transport_.connect();
<a name="line565"></a>
<a name="line566"></a>  // Now we run any deferred deliveries collected while connection was deferred.
<a name="line567"></a>  while (this.deferredDeliveries_.length &gt; 0) {
<a name="line568"></a>    this.deferredDeliveries_.shift()();
<a name="line569"></a>  }
<a name="line570"></a>};
<a name="line571"></a>
<a name="line572"></a>
<a name="line573"></a>/**
<a name="line574"></a> * Closes the channel.
<a name="line575"></a> */
<a name="line576"></a>goog.net.xpc.CrossPageChannel.prototype.close = function() {
<a name="line577"></a>  this.cleanUpIncompleteConnection_();
<a name="line578"></a>  this.state_ = goog.net.xpc.ChannelStates.CLOSED;
<a name="line579"></a>  goog.dispose(this.transport_);
<a name="line580"></a>  this.transport_ = null;
<a name="line581"></a>  this.connectCb_ = null;
<a name="line582"></a>  goog.dispose(this.connectionDelay_);
<a name="line583"></a>  this.connectionDelay_ = null;
<a name="line584"></a>  goog.net.xpc.logger.info(&#39;Channel &quot;&#39; + this.name + &#39;&quot; closed&#39;);
<a name="line585"></a>};
<a name="line586"></a>
<a name="line587"></a>
<a name="line588"></a>/**
<a name="line589"></a> * Package-private.
<a name="line590"></a> * Called by the transport when the channel is connected.
<a name="line591"></a> * @param {number=} opt_delay Delay this number of milliseconds before calling
<a name="line592"></a> *     the connection callback. Usage is discouraged, but can be used to paper
<a name="line593"></a> *     over timing vulnerabilities when there is no alternative.
<a name="line594"></a> */
<a name="line595"></a>goog.net.xpc.CrossPageChannel.prototype.notifyConnected = function(opt_delay) {
<a name="line596"></a>  if (this.isConnected() ||
<a name="line597"></a>      (this.connectionDelay_ &amp;&amp; this.connectionDelay_.isActive())) {
<a name="line598"></a>    return;
<a name="line599"></a>  }
<a name="line600"></a>  this.state_ = goog.net.xpc.ChannelStates.CONNECTED;
<a name="line601"></a>  goog.net.xpc.logger.info(&#39;Channel &quot;&#39; + this.name + &#39;&quot; connected&#39;);
<a name="line602"></a>  goog.dispose(this.connectionDelay_);
<a name="line603"></a>  if (opt_delay) {
<a name="line604"></a>    this.connectionDelay_ =
<a name="line605"></a>        new goog.async.Delay(this.connectCb_, opt_delay);
<a name="line606"></a>    this.connectionDelay_.start();
<a name="line607"></a>  } else {
<a name="line608"></a>    this.connectionDelay_ = null;
<a name="line609"></a>    this.connectCb_();
<a name="line610"></a>  }
<a name="line611"></a>};
<a name="line612"></a>
<a name="line613"></a>
<a name="line614"></a>/**
<a name="line615"></a> * Alias for notifyConected, for backward compatibility reasons.
<a name="line616"></a> * @private
<a name="line617"></a> */
<a name="line618"></a>goog.net.xpc.CrossPageChannel.prototype.notifyConnected_ =
<a name="line619"></a>    goog.net.xpc.CrossPageChannel.prototype.notifyConnected;
<a name="line620"></a>
<a name="line621"></a>
<a name="line622"></a>/**
<a name="line623"></a> * Called by the transport in case of an unrecoverable failure.
<a name="line624"></a> * Package private. Do not call from outside goog.net.xpc.
<a name="line625"></a> */
<a name="line626"></a>goog.net.xpc.CrossPageChannel.prototype.notifyTransportError = function() {
<a name="line627"></a>  goog.net.xpc.logger.info(&#39;Transport Error&#39;);
<a name="line628"></a>  this.close();
<a name="line629"></a>};
<a name="line630"></a>
<a name="line631"></a>
<a name="line632"></a>/** @override */
<a name="line633"></a>goog.net.xpc.CrossPageChannel.prototype.send = function(serviceName, payload) {
<a name="line634"></a>  if (!this.isConnected()) {
<a name="line635"></a>    goog.net.xpc.logger.severe(&#39;Can\&#39;t send. Channel not connected.&#39;);
<a name="line636"></a>    return;
<a name="line637"></a>  }
<a name="line638"></a>  // Check if the peer is still around.
<a name="line639"></a>  if (!this.isPeerAvailable()) {
<a name="line640"></a>    goog.net.xpc.logger.severe(&#39;Peer has disappeared.&#39;);
<a name="line641"></a>    this.close();
<a name="line642"></a>    return;
<a name="line643"></a>  }
<a name="line644"></a>  if (goog.isObject(payload)) {
<a name="line645"></a>    payload = goog.json.serialize(payload);
<a name="line646"></a>  }
<a name="line647"></a>
<a name="line648"></a>  // Partially URL-encode the service name because some characters (: and |) are
<a name="line649"></a>  // used as delimiters for some transports, and we want to allow those
<a name="line650"></a>  // characters in service names.
<a name="line651"></a>  this.transport_.send(this.escapeServiceName_(serviceName), payload);
<a name="line652"></a>};
<a name="line653"></a>
<a name="line654"></a>
<a name="line655"></a>/**
<a name="line656"></a> * Delivers messages to the appropriate service-handler. Named xpcDeliver to
<a name="line657"></a> * avoid name conflict with {@code deliver} function in superclass
<a name="line658"></a> * goog.messaging.AbstractChannel.
<a name="line659"></a> *
<a name="line660"></a> * Package private. Do not call from outside goog.net.xpc.
<a name="line661"></a> *
<a name="line662"></a> * @param {string} serviceName The name of the port.
<a name="line663"></a> * @param {string} payload The payload.
<a name="line664"></a> * @param {string=} opt_origin An optional origin for the message, where the
<a name="line665"></a> *     underlying transport makes that available.  If this is specified, and
<a name="line666"></a> *     the PEER_HOSTNAME parameter was provided, they must match or the message
<a name="line667"></a> *     will be rejected.
<a name="line668"></a> */
<a name="line669"></a>goog.net.xpc.CrossPageChannel.prototype.xpcDeliver = function(
<a name="line670"></a>    serviceName, payload, opt_origin) {
<a name="line671"></a>
<a name="line672"></a>  // This check covers the very rare (but producable) case where the inner frame
<a name="line673"></a>  // becomes ready and sends its setup message while the outer frame is
<a name="line674"></a>  // deferring its connect method waiting for the inner frame to be ready. The
<a name="line675"></a>  // resulting deferral ensures the message will not be processed until the
<a name="line676"></a>  // channel is fully configured.
<a name="line677"></a>  if (this.peerWindowDeferred_) {
<a name="line678"></a>    this.deferredDeliveries_.push(
<a name="line679"></a>        goog.bind(this.xpcDeliver, this, serviceName, payload, opt_origin));
<a name="line680"></a>    return;
<a name="line681"></a>  }
<a name="line682"></a>
<a name="line683"></a>  // Check whether the origin of the message is as expected.
<a name="line684"></a>  if (!this.isMessageOriginAcceptable_(opt_origin)) {
<a name="line685"></a>    goog.net.xpc.logger.warning(&#39;Message received from unapproved origin &quot;&#39; +
<a name="line686"></a>        opt_origin + &#39;&quot; - rejected.&#39;);
<a name="line687"></a>    return;
<a name="line688"></a>  }
<a name="line689"></a>
<a name="line690"></a>  if (this.isDisposed()) {
<a name="line691"></a>    goog.net.xpc.logger.warning(&#39;CrossPageChannel::xpcDeliver(): Disposed.&#39;);
<a name="line692"></a>  } else if (!serviceName ||
<a name="line693"></a>      serviceName == goog.net.xpc.TRANSPORT_SERVICE_) {
<a name="line694"></a>    this.transport_.transportServiceHandler(payload);
<a name="line695"></a>  } else {
<a name="line696"></a>    // only deliver messages if connected
<a name="line697"></a>    if (this.isConnected()) {
<a name="line698"></a>      this.deliver(this.unescapeServiceName_(serviceName), payload);
<a name="line699"></a>    } else {
<a name="line700"></a>      goog.net.xpc.logger.info(
<a name="line701"></a>          &#39;CrossPageChannel::xpcDeliver(): Not connected.&#39;);
<a name="line702"></a>    }
<a name="line703"></a>  }
<a name="line704"></a>};
<a name="line705"></a>
<a name="line706"></a>
<a name="line707"></a>/**
<a name="line708"></a> * Escape the user-provided service name for sending across the channel. This
<a name="line709"></a> * URL-encodes certain special characters so they don&#39;t conflict with delimiters
<a name="line710"></a> * used by some of the transports, and adds a special prefix if the name
<a name="line711"></a> * conflicts with the reserved transport service name.
<a name="line712"></a> *
<a name="line713"></a> * This is the opposite of {@link #unescapeServiceName_}.
<a name="line714"></a> *
<a name="line715"></a> * @param {string} name The name of the service to escape.
<a name="line716"></a> * @return {string} The escaped service name.
<a name="line717"></a> * @private
<a name="line718"></a> */
<a name="line719"></a>goog.net.xpc.CrossPageChannel.prototype.escapeServiceName_ = function(name) {
<a name="line720"></a>  if (goog.net.xpc.CrossPageChannel.TRANSPORT_SERVICE_ESCAPE_RE_.test(name)) {
<a name="line721"></a>    name = &#39;%&#39; + name;
<a name="line722"></a>  }
<a name="line723"></a>  return name.replace(/[%:|]/g, encodeURIComponent);
<a name="line724"></a>};
<a name="line725"></a>
<a name="line726"></a>
<a name="line727"></a>/**
<a name="line728"></a> * Unescape the escaped service name that was sent across the channel. This is
<a name="line729"></a> * the opposite of {@link #escapeServiceName_}.
<a name="line730"></a> *
<a name="line731"></a> * @param {string} name The name of the service to unescape.
<a name="line732"></a> * @return {string} The unescaped service name.
<a name="line733"></a> * @private
<a name="line734"></a> */
<a name="line735"></a>goog.net.xpc.CrossPageChannel.prototype.unescapeServiceName_ = function(name) {
<a name="line736"></a>  name = name.replace(/%[0-9a-f]{2}/gi, decodeURIComponent);
<a name="line737"></a>  if (goog.net.xpc.CrossPageChannel.TRANSPORT_SERVICE_UNESCAPE_RE_.test(name)) {
<a name="line738"></a>    return name.substring(1);
<a name="line739"></a>  } else {
<a name="line740"></a>    return name;
<a name="line741"></a>  }
<a name="line742"></a>};
<a name="line743"></a>
<a name="line744"></a>
<a name="line745"></a>/**
<a name="line746"></a> * Returns the role of this channel (either inner or outer).
<a name="line747"></a> * @return {number} The role of this channel.
<a name="line748"></a> */
<a name="line749"></a>goog.net.xpc.CrossPageChannel.prototype.getRole = function() {
<a name="line750"></a>  var role = this.cfg_[goog.net.xpc.CfgFields.ROLE];
<a name="line751"></a>  if (role) {
<a name="line752"></a>    return role;
<a name="line753"></a>  } else {
<a name="line754"></a>    return window.parent == this.peerWindowObject_ ?
<a name="line755"></a>        goog.net.xpc.CrossPageChannelRole.INNER :
<a name="line756"></a>        goog.net.xpc.CrossPageChannelRole.OUTER;
<a name="line757"></a>  }
<a name="line758"></a>};
<a name="line759"></a>
<a name="line760"></a>
<a name="line761"></a>/**
<a name="line762"></a> * Returns whether an incoming message with the given origin is acceptable.
<a name="line763"></a> * If an incoming request comes with a specified (non-empty) origin, and the
<a name="line764"></a> * PEER_HOSTNAME config parameter has also been provided, the two must match,
<a name="line765"></a> * or the message is unacceptable.
<a name="line766"></a> * @param {string=} opt_origin The origin associated with the incoming message.
<a name="line767"></a> * @return {boolean} Whether the message is acceptable.
<a name="line768"></a> * @private
<a name="line769"></a> */
<a name="line770"></a>goog.net.xpc.CrossPageChannel.prototype.isMessageOriginAcceptable_ = function(
<a name="line771"></a>    opt_origin) {
<a name="line772"></a>  var peerHostname = this.cfg_[goog.net.xpc.CfgFields.PEER_HOSTNAME];
<a name="line773"></a>  return goog.string.isEmptySafe(opt_origin) ||
<a name="line774"></a>      goog.string.isEmptySafe(peerHostname) ||
<a name="line775"></a>      opt_origin == this.cfg_[goog.net.xpc.CfgFields.PEER_HOSTNAME];
<a name="line776"></a>};
<a name="line777"></a>
<a name="line778"></a>
<a name="line779"></a>/** @override */
<a name="line780"></a>goog.net.xpc.CrossPageChannel.prototype.disposeInternal = function() {
<a name="line781"></a>  this.close();
<a name="line782"></a>
<a name="line783"></a>  this.peerWindowObject_ = null;
<a name="line784"></a>  this.iframeElement_ = null;
<a name="line785"></a>  delete goog.net.xpc.channels[this.name];
<a name="line786"></a>  goog.dispose(this.peerLoadHandler_);
<a name="line787"></a>  delete this.peerLoadHandler_;
<a name="line788"></a>  goog.base(this, &#39;disposeInternal&#39;);
<a name="line789"></a>};
<a name="line790"></a>
<a name="line791"></a>
<a name="line792"></a>/**
<a name="line793"></a> * Disposes all channels.
<a name="line794"></a> * @private
<a name="line795"></a> */
<a name="line796"></a>goog.net.xpc.CrossPageChannel.disposeAll_ = function() {
<a name="line797"></a>  for (var name in goog.net.xpc.channels) {
<a name="line798"></a>    goog.dispose(goog.net.xpc.channels[name]);
<a name="line799"></a>  }
<a name="line800"></a>};
</pre>


</body>
</html>
